/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "abonoContrato")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AbonoContrato.findAll", query = "SELECT a FROM AbonoContrato a"),
    @NamedQuery(name = "AbonoContrato.findByFkContrato", query = "SELECT a FROM AbonoContrato a WHERE a.abonoContratoPK.fkContrato = :fkContrato"),
    @NamedQuery(name = "AbonoContrato.findByFkAbono", query = "SELECT a FROM AbonoContrato a WHERE a.abonoContratoPK.fkAbono = :fkAbono"),
    @NamedQuery(name = "AbonoContrato.findByValor", query = "SELECT a FROM AbonoContrato a WHERE a.valor = :valor"),
    @NamedQuery(name = "AbonoContrato.findByTipoAbono", query = "SELECT a FROM AbonoContrato a WHERE a.tipoAbono = :tipoAbono")})
public class AbonoContrato implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AbonoContratoPK abonoContratoPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "valor")
    private double valor;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "tipoAbono")
    private String tipoAbono;
    @JoinColumn(name = "fkAbono", referencedColumnName = "idAbono", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Abono abono;
    @JoinColumn(name = "fkContrato", referencedColumnName = "idContrato", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Contrato contrato;

    public AbonoContrato() {
    }

    public AbonoContrato(AbonoContratoPK abonoContratoPK) {
        this.abonoContratoPK = abonoContratoPK;
    }

    public AbonoContrato(AbonoContratoPK abonoContratoPK, double valor, String tipoAbono) {
        this.abonoContratoPK = abonoContratoPK;
        this.valor = valor;
        this.tipoAbono = tipoAbono;
    }

    public AbonoContrato(int fkContrato, int fkAbono) {
        this.abonoContratoPK = new AbonoContratoPK(fkContrato, fkAbono);
    }

    public AbonoContratoPK getAbonoContratoPK() {
        return abonoContratoPK;
    }

    public void setAbonoContratoPK(AbonoContratoPK abonoContratoPK) {
        this.abonoContratoPK = abonoContratoPK;
    }

    public double getValor() {
        return valor;
    }

    public void setValor(double valor) {
        this.valor = valor;
    }

    public String getTipoAbono() {
        return tipoAbono;
    }

    public void setTipoAbono(String tipoAbono) {
        this.tipoAbono = tipoAbono;
    }

    public Abono getAbono() {
        return abono;
    }

    public void setAbono(Abono abono) {
        this.abono = abono;
    }

    public Contrato getContrato() {
        return contrato;
    }

    public void setContrato(Contrato contrato) {
        this.contrato = contrato;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (abonoContratoPK != null ? abonoContratoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AbonoContrato)) {
            return false;
        }
        AbonoContrato other = (AbonoContrato) object;
        if ((this.abonoContratoPK == null && other.abonoContratoPK != null) || (this.abonoContratoPK != null && !this.abonoContratoPK.equals(other.abonoContratoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.AbonoContrato[ abonoContratoPK=" + abonoContratoPK + " ]";
    }
    
}
